home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # This checks IP address syntax.
- # usage: syntax_check ADDRESS #-OF-EXPECTED-SEGMENTS (up to 4)
- # example: syntax_check 123.22.43.1 4
- # returns: 0=found correct 1=too many fields 2=non numeric field found
- TMP=/var/log/setup/tmp
- if [ ! -d $TMP ]; then
- mkdir -p $TMP
- chmod 700 $TMP
- fi
- syntax_check_color() {
- RET_CODE=0
- SCRATCH=$1
- SCRATCH=`echo $SCRATCH | tr "." "/"`
- INDEX=$2
- while [ ! "$INDEX" = "0" ]; do
- # OK, so I'm a LISP-head :^)
- FIELD=`basename $SCRATCH`
- SCRATCH=`dirname $SCRATCH`
- if expr $FIELD + 1 1> /dev/null 2> /dev/null; then
- GOOD=y
- else
- RET_CODE=2; # non-numeric field
- fi
- INDEX=`expr $INDEX - 1`
- done
- if [ ! "$SCRATCH" = "." ]; then
- RET_CODE=1; # too many arguments
- fi
- if [ "$3" = "WARN" -a ! "$RET_CODE" = "0" ]; then
- cat << EOF > $TMP/tempmsg
-
- The address you have entered seems to be non-standard. We were expecting
- $2 groups of numbers seperated by dots, like: 127.0.0.1
- Are you absolutely sure you want to use the address $1?
-
- EOF
- dialog --title "WARNING" --yesno "`cat $TMP/tempmsg`" 9 72
- if [ $? = 0 ]; then
- RET_CODE = 0;
- fi
- rm -r $TMP/tempmsg
- else
- if [ "$3" = "ECHO" ]; then
- echo $RET_CODE;
- fi
- fi
- return $RET_CODE;
- }
-
- if [ ! -d lost+found -a ! -d vmlinuz -a ! -d proc ]; then # cheap, but it works :^)
- cd /
- fi;
-
- # IMPORTANT!!! NO LEADING '/' in the paths below, or this script will not
- # function from the bootdisk.
- IFCONFIG=sbin/ifconfig # Where ifconfig program is.
- ROUTE=sbin/route # Where route program is.
- RC=etc/rc.d/rc.inet1 # Where rc.inet1 file is.
- RESOLV=etc/resolv.conf # Where resolv.conf file is.
- HOSTS=etc/hosts # Where hosts file is.
- ETCNETWORKS=etc/networks # Where networks file is.
- SMAIL=var/lib/smail/config # Smail configuration file
- ELMRC=var/lib/elm/elm.rc # ELM rc file
- #
- # defaults:
- NETWORK=127.0.0.0
- IPADDR=127.0.0.1
- NETMASK=255.255.255.0
- #
- ############################################################################
- # Question and answer.
- ############################################################################
- #
- cat << EOF > $TMP/tempmsg
-
- Now we will attempt to configure your mail and TCP/IP. This
- process probably won't work on all possible network
- configurations, but should give you a good start. You will be
- able to reconfigure your system at any time by typing:
-
- netconfig
-
- EOF
- dialog --title "NETWORK CONFIGURATION" --msgbox "`cat $TMP/tempmsg`" 12 70
- while [ 0 ]; do
- cat << EOF > $TMP/tempmsg
- First, we'll need the name you'd like to give your host. Only
- the base hostname is needed right now. (not the domain)
-
- Enter hostname:
- EOF
- dialog --title "ENTER HOSTNAME" --inputbox "`cat $TMP/tempmsg`" 11 70 \
- $HOSTNM 2> $TMP/SeThost
- if [ $? = 1 -o $? = 255 ]; then
- rm -f $TMP/SeThost $TMP/tempmsg
- exit
- fi
- HOSTNM="`cat $TMP/SeThost`"
- rm -f $TMP/SeThost $TMP/tempmsg
- if [ ! "$HOSTNM" = "" ]; then
- break;
- fi
- done
-
- while [ 0 ]; do
- cat << EOF > $TMP/tempmsg
- Now, we need the domain name. Do not supply a leading '.'
-
- Enter domain name for $HOSTNM:
- EOF
- dialog --title "ENTER DOMAINNAME" --inputbox "`cat $TMP/tempmsg`" \
- 10 70 $DOMAIN 2> $TMP/SeTdom
- if [ $? = 1 -o $? = 255 ]; then
- rm -f $TMP/SeTdom $TMP/tempmsg
- exit
- fi
- DOMAIN="`cat $TMP/SeTdom`"
- rm -f $TMP/SeTdom $TMP/tempmsg
- if [ ! "$DOMAIN" = "" ]; then
- break;
- fi
- done
-
- echo $HOSTNM.$DOMAIN > etc/HOSTNAME
-
- cat << EOF > $TMP/tempmsg
- If you only plan to use TCP/IP through loopback, then your
- IP address will be 127.0.0.1 and we can skip a lot of the
- following questions.
-
- Do you plan to ONLY use loopback?
- EOF
- dialog --title "LOOPBACK ONLY?" --yesno "`cat $TMP/tempmsg`" 9 70
- if [ $? = 0 ]; then
- LOOPBACK="y"
- else
- LOOPBACK="n"
- fi
-
- if [ -r bin/telnet -a "$LOOPBACK" = "n" ]; then
-
- while [ 0 ]; do
- if [ -r $TMP/SeTIP ]; then
- IPADDR=`cat $TMP/SeTIP`
- fi
- cat << EOF > $TMP/tempmsg
- Enter your IP address for the local machine. Example:
- 111.112.113.114
- Enter IP address for $HOSTNM (aaa.bbb.ccc.ddd):
- EOF
- dialog --title "ENTER LOCAL IP ADDRESS" --inputbox "`cat $TMP/tempmsg`" \
- 10 68 $IPADDR 2> $TMP/SeTlip
- if [ $? = 1 -o $? = 255 ]; then
- rm -f $TMP/SeTlip $TMP/tempmsg
- exit
- fi
- IPADDR="`cat $TMP/SeTlip`"
- rm -f $TMP/SeTlip $TMP/tempmsg
- if [ "$IPADDR" = "" ]; then
- continue;
- fi
- syntax_check_color $IPADDR 4 WARN
- if [ $? = 0 ]; then
- echo $IPADDR > $TMP/SeTIP
- break;
- fi
- done
-
- while [ 0 ]; do
- if [ -r $TMP/SeTnetmask ]; then
- NETMASK=`cat $TMP/SeTnetmask`
- fi
- cat << EOF > $TMP/tempmsg
- Enter your netmask. This will generally look something
- like this: 255.255.255.0
- Enter netmask (aaa.bbb.ccc.ddd):
- EOF
- dialog --title "ENTER NETMASK" --inputbox "`cat $TMP/tempmsg`" \
- 10 65 $NETMASK 2> $TMP/SeTnmask
- if [ $? = 1 -o $? = 255 ]; then
- rm -f $TMP/SeTnmask $TMP/tempmsg
- exit
- fi
- NETMASK="`cat $TMP/SeTnmask`"
- rm -f $TMP/SeTnmask $TMP/tempmsg
- if [ "$NETMASK" = "" ]; then
- continue;
- fi
- syntax_check_color $NETMASK 4 WARN
- if [ $? = 0 ]; then
- echo $NETMASK > $TMP/SeTnetmask
- break;
- fi
- done
-
- # Set broadcast/network addresses automatially:
-
- BROADCAST=`ipmask $NETMASK $IPADDR | cut -f 1 -d ' '`
- NETWORK=`ipmask $NETMASK $IPADDR | cut -f 2 -d ' '`
-
- while [ 0 ]; do
- if [ -r $TMP/SeTgateway ]; then
- GATEWAY=`cat $TMP/SeTgateway`
- fi
- cat << EOF > $TMP/tempmsg
- Enter your gateway address, such as 111.112.113.1
-
- If you don't have a gateway on your network, just hit
- ENTER without entering a gateway IP address.
-
- Enter gateway address (aaa.bbb.ccc.ddd):
- EOF
- dialog --title "ENTER GATEWAY ADDRESS" --inputbox "`cat $TMP/tempmsg`" \
- 13 65 $GATEWAY 2> $TMP/SeTgate
- if [ $? = 1 -o $? = 255 ]; then
- rm -f $TMP/SeTgate $TMP/tempmsg
- exit
- fi
- GATEWAY="`cat $TMP/SeTgate`"
- rm -f $TMP/SeTgate $TMP/tempmsg
- if [ "$GATEWAY" = "" ]; then
- break;
- fi
- syntax_check_color $GATEWAY 4 WARN
- if [ $? = 0 ]; then
- echo $GATEWAY > $TMP/SeTgateway
- break;
- fi
- done
-
- else
- if [ ! -r bin/telnet ]; then
- cat << EOF > $TMP/tempmsg
-
- You do not seem to have TCP/IP installed, so all I can really set
- up for you is your hostname/domainname. This won't mean much
- since you're not on the network, but it will let you have the
- hostname you prefer shown at the login prompt.
-
- EOF
- dialog --title "SKIPPING MOST OF THE CONFIG PROCESS" \
- --infobox "`cat $TMP/tempmsg`" 10 70
- fi
- fi
-
- #
- ############################################################################
- # The rc.inet1 file.
- ############################################################################
- #
- # echo "Creating /$RC..."
- if [ "$LOOPBACK" = "n" ]; then # we are using an ethernet card
- /bin/cat <<EOF >$RC
- #! /bin/sh
- #
- # rc.inet1 This shell script boots up the base INET system.
- #
- # Version: @(#)/etc/rc.d/rc.inet1 1.01 05/27/93
- #
-
- HOSTNAME=\`cat /etc/HOSTNAME\`
-
- # Attach the loopback device.
- /$IFCONFIG lo 127.0.0.1
- /$ROUTE add -net 127.0.0.0 netmask 255.0.0.0 lo
-
- # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the
- # eth0 interface. If you're only using loopback or SLIP, don't include the
- # rest of the lines in this file.
-
- # Edit for your setup.
- IPADDR="$IPADDR" # REPLACE with YOUR IP address!
- NETMASK="$NETMASK" # REPLACE with YOUR netmask!
- NETWORK="$NETWORK" # REPLACE with YOUR network address!
- BROADCAST="$BROADCAST" # REPLACE with YOUR broadcast address, if you
- # have one. If not, leave blank and edit below.
- GATEWAY="$GATEWAY" # REPLACE with YOUR gateway address!
-
- # Uncomment the line below to configure your ethernet card.
- /$IFCONFIG eth0 \${IPADDR} broadcast \${BROADCAST} netmask \${NETMASK}
-
- # If the line above is uncommented, the code below can also be uncommented.
- # It sees if the ethernet was properly initialized, and gives the admin some
- # hints about what to do if it wasn't.
- if [ ! \$? = 0 ]; then
- cat << END
- Your ethernet card was not initialized properly. Here are some reasons why this
- may have happened, and the solutions:
- 1. Your kernel does not contain support for your card. Including all the
- network drivers in a Linux kernel can make it too large to even boot, and
- sometimes including extra drivers can cause system hangs. To support your
- ethernet, either edit /etc/rc.d/rc.modules to load the support at boottime,
- or compile and install a kernel that contains support.
- 2. You don't have an ethernet card, in which case you should comment out this
- section of /etc/rc.d/rc.inet1. (Unless you don't mind seeing this error...)
- END
- fi
-
- # Older kernel versions need this to set up the eth0 routing table:
- KVERSION=`uname -r | cut -f 1,2 -d .`
- if [ "\$KVERSION" = "1.0" -o "\$KVERSION" = "1.1" \\
- -o "\$KVERSION" = "1.2" -o "\$KVERSION" = "2.0" -o "\$KVERSION" = "" ]; then
- /$ROUTE add -net \${NETWORK} netmask \${NETMASK} eth0
- fi
-
- # Uncomment this to set up your gateway route:
- if [ ! "\$GATEWAY" = "" ]; then
- /$ROUTE add default gw \${GATEWAY} netmask 0.0.0.0 metric 1
- fi
-
- # End of rc.inet1
- EOF
- chmod 755 $RC
- else # we are only using loopback
- /bin/cat <<EOF >$RC
- #! /bin/sh
- #
- # rc.inet1 This shell script boots up the base INET system.
- #
- # Version: @(#)/etc/rc.d/rc.inet1 1.01 05/27/93
- #
-
- HOSTNAME=\`cat /etc/HOSTNAME\`
-
- # Attach the loopback device.
- /$IFCONFIG lo 127.0.0.1
- /$ROUTE add -net 127.0.0.0 netmask 255.0.0.0 lo
-
- # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the
- # eth0 interface. If you're only using loopback or SLIP, don't include the
- # rest of the lines in this file.
-
- # Edit for your setup.
- #IPADDR="$IPADDR" # REPLACE with YOUR IP address!
- #NETMASK="$NETMASK" # REPLACE with YOUR netmask!
- #NETWORK="$NETWORK" # REPLACE with YOUR network address!
- #BROADCAST="$BROADCAST" # REPLACE with YOUR broadcast address, if you
- # have one. If not, leave blank and edit below.
- #GATEWAY="$GATEWAY" # REPLACE with YOUR gateway address!
-
- # Uncomment the line below to initialize the ethernet device.
- #/$IFCONFIG eth0 \${IPADDR} broadcast \${BROADCAST} netmask \${NETMASK}
-
- # Uncomment these to set up your IP routing table.
- #/$ROUTE add -net \${NETWORK} netmask \${NETMASK} eth0
- #/$ROUTE add default gw \${GATEWAY} netmask 0.0.0.0 metric 1
-
- # End of rc.inet1
- EOF
- chmod 755 $RC
- fi # write out the script
- #
- ############################################################################
- # The networks file.
- ############################################################################
- #
- #echo "Creating /$ETCNETWORKS..."
- /bin/cat <<EOF >$ETCNETWORKS
- #
- # networks This file describes a number of netname-to-address
- # mappings for the TCP/IP subsystem. It is mostly
- # used at boot time, when no name servers are running.
- #
-
- loopback 127.0.0.0
- localnet $NETWORK
-
- # End of networks.
- EOF
- chmod 644 $ETCNETWORKS
- #
- ############################################################################
- # The hosts file.
- ############################################################################
- #
- #echo "Creating /$HOSTS..."
- /bin/cat <<EOF >$HOSTS
- #
- # hosts This file describes a number of hostname-to-address
- # mappings for the TCP/IP subsystem. It is mostly
- # used at boot time, when no name servers are running.
- # On small systems, this file can be used instead of a
- # "named" name server. Just add the names, addresses
- # and any aliases to this file...
- #
- # By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
- # should NEVER be named with the name of the machine. It causes problems
- # for some (stupid) programs, irc and reputedly talk. :^)
- #
-
- # For loopbacking.
- 127.0.0.1 localhost
- $IPADDR $HOSTNM.$DOMAIN $HOSTNM
-
- # End of hosts.
-
- EOF
- chmod 644 $HOSTS
- #
- ##########################################################################
- # The Smail 3.1.28 configuration file
- ##########################################################################
- #
- #mkdir -p `dirname $SMAIL`
- ##echo "Creating /$SMAIL..."
- #/bin/cat <<EOF >$SMAIL
- ##
- ## smail configuration for $HOSTNM
- ## (see smail(5) man page for details and other options)
- ##
- #-smtp_debug
- #hostname=$HOSTNM.$DOMAIN
- #visible_domain=$DOMAIN
- #more_hostnames=$HOSTNM.$DOMAIN
- #postmaster=postmaster
- #smtp_accept_max=10
- #EOF
- #echo 'smtp_banner="$primary_name Linux Smail$version #$compile_num ready at $date"' >> $SMAIL
- #echo 'received_field="Received: \' >> $SMAIL
- #echo ' ${if def:sender_host \' >> $SMAIL
- #echo ' {from $sender_host by $primary_name \' >> $SMAIL
- #echo ' ${if def:sender_proto: with $sender_proto}\' >> $SMAIL
- #echo ' \n\t(Linux Smail$version #$compile_num) }\' >> $SMAIL
- #echo ' else{by $primary_name ${if def:sender_proto:with $sender_proto }\' >> $SMAIL
- #echo ' (Linux Smail$version #$compile_num)\n\t}}\' >> $SMAIL
- #echo ' id $message_id; $spool_date"' >> $SMAIL
- #chmod 644 $SMAIL
- ##
- ############################################################################
- # The ELM rc file
- ############################################################################
- #
- mkdir -p `dirname $ELMRC`
- #echo "Creating /$ELMRC..."
- /bin/cat <<EOF >$ELMRC
- #------------------------ global elm.rc file ------------------
- #
- # this expects any global aliases in /usr/lib/aliases.text
- #
- # you probably also want to set the visible_name parameter in
- # /usr/lib/smail/config if you use smail3.1.28
- #
- # this is the unqualified hostname
- #
- hostname = $HOSTNM
- #
- # this is the local domain
- #
- hostdomain = .$DOMAIN
- #
- # this is the fully qualified hostname
- #
- hostfullname = $HOSTNM.$DOMAIN
- EOF
- chmod 644 $ELMRC
- #
- ############################################################################
- # The resolv.conf file.
- ############################################################################
- #
- if [ "$LOOPBACK" = "n" ]; then
- dialog --title "USE A NAMESERVER?" --yesno "Will you be accessing a \
- nameserver?" 5 50
- if [ $? = 0 ]; then
- while [ "$NAMESERVER" = "" ]; do
- cat << EOF > $TMP/tempmsg
- Here is your current IP address, full hostname, and base hostname:
- $IPADDR $HOSTNM.$DOMAIN $HOSTNM
-
- Please give the IP address of the name server to use.
- You can add more Domain Name Servers by editing /$RESOLV.
-
- Name Server for domain $DOMAIN (aaa.bbb.ccc.ddd):
- EOF
- dialog --title "SELECT NAMESERVER" --inputbox \
- "`cat $TMP/tempmsg`" 14 72 2> $TMP/SeTns
- if [ $? = 1 -o $? = 255 ]; then
- rm -f $TMP/tempmsg $TMP/SeTns
- fi
- NAMESERVER="`cat $TMP/SeTns`"
- rm -f $TMP/tempmsg $TMP/SeTns
- done
- echo "search $DOMAIN" >$RESOLV
- echo "nameserver $NAMESERVER" >>$RESOLV
- else
- echo "search $DOMAIN" >$RESOLV
- fi
- fi
- if [ "$LOOPBACK" = "n" ]; then chmod 644 $RESOLV ;fi
- #
- ############################################################################
- # Change permissions and exit.
- ############################################################################
- #
- dialog --title "NETWORK SETUP COMPLETE" --msgbox "Your networking \
- software has now been configured. IMPORTANT: Remember that most precompiled \
- Linux kernels do not have network drivers compiled into them, since \
- compiling them all in results in kernels that are too large to boot. \
- If you need a driver that is not present in your kernel, either \
- recompile the kernel to include the necessary driver or load the \
- driver as a module by editing /etc/rc.d/rc.modules." 11 64
- rm -f $TMP/tempmsg
-